package cn.hinglo.gameclaw.user.service;

import cn.hinglo.gameclaw.data.exception.ResultException;
import cn.hinglo.gameclaw.user.dao.ImageDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import static cn.hinglo.gameclaw.data.utils.FieldUtils.*;


/**
 * @createTime: 2018/1/2
 * @author: HingLo
 * @description: 图片访问的服务层
 */
@Service
public class ImageService {
    private final ImageDao imageDao;

    @Autowired
    public ImageService(ImageDao imageDao) {
        this.imageDao = imageDao;
    }

    public String findImageNameService(String id, int type) {
        switch (type) {
            //banner
            case IMAGE_1:
                return imageDao.findBannerImageDao(id);
            // /claw/details
            case IMAGE_2:
                return imageDao.findDetailsImageDao(id);
            // /claw/show
            case IMAGE_3:
                return imageDao.findShowImageDao(id);
            // /user/header
            case IMAGE_4:
                return imageDao.findHeaderImageDao(id);
            // /claw/money
            case IMAGE_5:
                return imageDao.findMoneyImageDao(id);
            case IMAGE_6:
                return imageDao.findQQImageDao(id);
            default:
                throw new ResultException(-1, "图片类型不正确");
        }
    }


}
